import {request} from "axios";

const AccessTokenKey = 'ACCESS_TOKEN'
const RefreshTokenKey = 'REFRESH_TOKEN'

// 获取 Token
export function getAccessToken() {
    return localStorage.getItem(AccessTokenKey)
}

// 设置 Token
export function setACCESSToken(token) {
    localStorage.setItem(AccessTokenKey, token)
}
// 删除 Token
export function removeACCESSToken() {
    localStorage.removeItem(AccessTokenKey)
}

export function getRefreshToken() {
    return localStorage.getItem(RefreshTokenKey)
}

// 设置 Token
export function setRefreshToken(token) {
    localStorage.setItem(RefreshTokenKey, token)
}

// 删除 Token
export function removeRefreshToken() {
    localStorage.removeItem(RefreshTokenKey)
}

// 刷新token
export function refreshToken(){
    const refreshToken = getRefreshToken()
    console.log(refreshToken)
    return request({
        url: '/user/refreshToken',
        method: "post",
        data:{
            refreshToken: refreshToken
        }
    })
}

